﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;



    public class datUser
    {
        SqlCommand cmd;
        SqlDataReader dr;
        public List<entUser> getUserDangNhap(entUser sv)
        {
            string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(constr);
            sqlConnection.Open();
            cmd = new SqlCommand("sp_UserDangNhap", sqlConnection);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter[] sqla = new SqlParameter[2];
            sqla[0] = new SqlParameter("username", DbType.String);
            sqla[1] = new SqlParameter("pass", DbType.String);

            sqla[0].Value = sv.UserName;
            sqla[1].Value = sv.Pass;
            cmd.Parameters.AddRange(sqla);

            dr = cmd.ExecuteReader();
            entUser entsv = new entUser();
            List<entUser> lst = new List<entUser>();
            while (dr.Read())
            {
                entsv = new entUser();
                entsv.UserName = dr["Userid"].ToString();
                entsv.Pass = dr["Username"].ToString();
                lst.Add(entsv);
            }
            dr.Close();
            sqlConnection.Close();
            return lst;
        }
    }

